<admintpl file="header"/>

</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:U('indexmy/login')}">本站用户</a></li>
        <li><a href="{:U('indexmy/adduser')}">添加用户</a></li>
    </ul>
    <form class="well form-search" method="post" action="{:U('Indexmy/login')}">
        用户ID：
        <input type="text" name="uid" style="width: 100px;" value="{:I('request.uid')}" placeholder="请输入用户ID">
        关键字：
        <input type="text" name="keyword" style="width: 200px;" value="{:I('request.keyword')}" placeholder="用户名/昵称/邮箱">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:U('Indexmy/login')}">清空</a>
    </form>
    <form method="post" class="js-ajax-form">
        <table class="table table-bordered">
            <thead>
            <tr>
                <th align="center">ID</th>
                <th>用户名</th>
                <th>昵称</th>
                <th>邮箱</th>
                <th>注册时间</th>
                <th>最后登录时间</th>
                <th>最后登录IP</th>
                <th align="center">操作</th>
            </tr>
            </thead>

            <php>
                $user_statuses=array("0"=>L('USER_STATUS_BLOCKED'),"1"=>L('USER_STATUS_ACTIVATED'),"2"=>L('USER_STATUS_UNVERIFIED'));
            </php>
            <foreach name="list" item="vo">
                <tr>
                    <td align="center">{$vo.id}</td>
                    <td>{$vo['user_login']?$vo['user_login']:($vo['mobile']?$vo['mobile']:L('THIRD_PARTY_USER'))}</td>
                    <td>{$vo['user_nicename']?$vo['user_nicename']:L('NOT_FILLED')}</td>
                    <td>{$vo.user_email}</td>
                    <td>{$vo.create_time}</td>
                    <td>{$vo.last_login_time}</td>
                    <td>{$vo.last_login_ip}</td>
                    <td>
                        <a href="#" data-toggle='modal' data-target='#example'
                           style="color: #ccc;" onclick='hq("{$vo.id}")'>修改</a>|
                        <a href="#" id="btn_sc" style="color: red;" onclick="sc('{$vo.id}')">删除</a>
                    </td>
                </tr>
            </foreach>
        </table>
        <div class="pagination">{$page}</div>
    </form>

    <div class="container">
        <div id="example" class="modal hide fade in" style="display: none; ">
            <div class="modal-body">
                <h4>用户信息</h4>
                <form method="post" class="form-horizontal js-ajax-form">
                    <fieldset>
                        <div class="control-group">
                            <label class="control-label">用户名:</label>
                            <div class="controls">
                                <input type="text" id="user_login" name="user_login">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">密码:</label>
                            <div class="controls">
                                <input type="password" id="user_pass" name="user_pass">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">邮箱:</label>
                            <div class="controls">
                                <input type="text" id="user_email" name="user_email">
                            </div>
                        </div>
                    </fieldset>
                    <div class="form-actions">
                        <a href="#" id="btn" class="btn btn-success">确定</a>
                        <a href="#" class="btn" data-dismiss="modal">取消</a>
                        <span id="mess" style="color: red;"></span>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script>
    $('#mess').hide();

    function hq(id) {
        $('#btn').click(function () {
            var user_login = $('#user_login').val();
            var user_pass = $('#user_pass').val();
            var user_email = $('#user_email').val();
            $.post("{:U('indexmy/modify')}", {
                'id': id,
                'user_login': user_login,
                'user_pass': user_pass,
                'user_email': user_email
            }, function (o) {
                console.log(o);
                if (o == 333) {
                    $('#mess').show();
                    $('#mess').html('此用户已存在，请重新修改！');
                    location.href = "{:U('indexmy/login')}";
                } else {
                    if (o == 111) {
                        $('#mess').show();
                        $('#mess').html('修改成功！');
                        location.href = "{:U('indexmy/login')}";
                    } else {
                        $('#mess').show();
                        $('#mess').html('修改失败!');
                        location.href = "{:U('indexmy/login')}";
                    }
                }

            });
            return false;
        });
    }

    function sc(id) {
        $.post("{:U('Indexmy/dele')}", {'id': id}, function (o) {
            if (o == 111) {
                alert('删除成功！');
                location.href = "{:U('indexmy/login')}";
            } else {
                console.log('删除失败！');
            }
        });
        return false;

    }


</script>
</body>
